<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="../common/public_header_main.jsp"%>

<link href="${ctx_static }/home/configuration/css/partnerManage.css" rel="stylesheet">
                
<div class="row" id="partner">
    <div class="col-lg-12 col-sm-12 col-xs-12">
        <div class="widget">
            <div class="widget-header">
                <div class="widget-buttons">
                    <a href="#" data-toggle="collapse">
                        <i class="fa fa-minus"></i>
                    </a>
                    <a href="#" data-toggle="dispose">
                        <i class="fa fa-times"></i>
                    </a>
                </div>
                <!--Widget Buttons-->
            </div>
            <!--Widget Header-->
            <div class="widget-body">
                <div class="widget-main ">
                    <div class="row row_padding form-horizontal">
                        <div class="col-lg-6 col-md-9 col-sm-9 col-xs-12">
                            <div class="form-group col-lg-7 col-md-7 col-sm-7 no-margin-right">
                                <input type="text" class="form-control searchVal" 
                                       placeholder="合作方编号/合作单位名称/合作单位简称/首要联系人/联系方式" onkeydown="search();">
                            </div>
                            <div class="form-group col-lg-3 col-md-3 col-sm-3 no-margin-right">
                                <select class="form-control" name="status">
                                    <option value="">状态</option>
                                    <option value="0">禁用</option>
                                    <option value="1">启用</option>
                                </select>
                            </div>
                            <div class="form-group col-lg-2 col-md-2 col-sm-2">
                                <button type="button"
                                        class="btn btn-blue form-control search-btn">
                                    搜索
                                </button>
                            </div>
                        </div>

                        <div class="col-md-3 col-sm-3 col-xs-12 btn-group pull-right">
                            <span class="btn btn-default pointer"
                                  title="View print view"><span>打印</span></span>
                            <div class="btn-group">
                                <button type="button" class="btn btn-default dropdown-toggle"
                                        data-toggle="dropdown">
                                    导出
                                    <i class="fa fa-angle-up"></i>
                                </button>
                                <ul class="dropdown-menu" role="menu">
                                    <li><a href="#">保存PDF</a></li>
                                    <li><a href="#">导出EXCEL</a></li>
                                    <li><a href="#">导出CSV</a></li>
                                </ul>
                            </div>
                            <shiro:hasPermission name="bizPartner:add">
                            <button class="btn btn-blue pull-right col-sm-4" data-toggle="modal"
                                    data-target=".partnerAdd" data-backdrop="static">新增
                                <i class="fa fa-plus-square-o right"></i></button>
                            </shiro:hasPermission>
                        </div>
                    </div>
                        <table id="partnerTable" class="table table-striped table-hover table-bordered dataTable no-footer">
                            <thead>
                            <tr role="row">
                                <th width="5%">
                                    <label>
                                        <input type="checkbox">
                                        <span class="text"></span>
                                    </label>
                                </th>
                                <th>合作方编号 </span>
                                </th>
                                <th>归属</th>
                                <th>合作单位名称 </span>
                                </th>
                                <th>合作单位简称 </span>
                                </th>
                                <th>首要联系人 </span>
                                </th>
                                <th>联系方式 </span>
                                </th>
                                <th>状态 </span>
                                </th>
                                <th>操作</th>
                            </tr>
                            </thead>

                            <tbody>
                            <!-- <tr>
                                <td>
                                    <label>
                                        <input type="checkbox">
                                        <span class="text"></span>
                                    </label>
                                </td>
                                <td>00001610</td>
                                <td>00集团</td>
                                <td>武汉金英汇教育投资有限公司</td>
                                <td>金英汇</td>
                                <td>刘君</td>
                                <td>25658456252</td>
                                <td>
                                    <a href="#" class="btn btn-use btn-xs status-btn"><i
                                            class="fa fa-check-square-o"></i> 启用</a>
                                </td>
                                <td>
                                    <a href="contractManage.html" class="btn btn-info btn-xs">
                                        <i class="fa fa-edit"></i> 合同管理</a>
                                    <a href="#" class="btn btn-info btn-xs edit margin-left-5"
                                       data-toggle="modal"
                                       data-target=".partnerEdit"
                                       data-backdrop="static">
                                        <i class="fa fa-edit"></i> 编辑</a>
                                </td>
                            </tr> -->
                            </tbody>
                        </table>
                </div>

            </div>
        </div>
    </div>
</div>

<!--合作方新增-->
<div class="modal fade partnerAdd" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel"
     aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header bordered-blue">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span
                        class="sr-only">Close</span></button>
                <span class="widget-caption">新增</span>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" id="partnerAdd" onsubmit="return validateForm()">
                
                	<input name="partnerId" type="hidden"/>
                	
                    <div class="form-group col-sm-6 margin-left-5">
                        <label class="control-label col-sm-4 no-padding-right">资源归属
<span class="control-label mandatory">*</span></label>
                        <div class="col-sm-7">
                            <select name="departmentId" class="form-control">
                            </select>
                        </div>
                    </div>
                    <div class="form-group col-sm-6 margin-left">
                        <label class="control-label col-sm-4 no-padding-right">合作方编号
<span class="control-label mandatory">*</span></label>
                        <div class="col-sm-7">
                            <input name="partnerCode" class="form-control" >
                        </div>
                    </div>
                    <div class="form-group col-sm-6 margin-left-5">
                        <label class="control-label col-sm-4 no-padding-right">合作单位名称
<span class="control-label mandatory">*</span></label>
                        <div class="col-sm-7">
                            <input name="partnerName" class="form-control" >
                        </div>
                    </div>
                    <div class="form-group col-sm-6 margin-left">
                        <label class="control-label col-sm-4 no-padding-right">合作单位简称
<span class="control-label mandatory">*</span></label>
                        <div class="col-sm-7">
                            <input name="partnerShortName" class="form-control">
                        </div>
                    </div>
                    <div class="form-group col-sm-12">
                        <label class="control-label col-sm-2 no-padding-right">合作单位地址
<span class="control-label mandatory">*</span></label>
                        <div class="col-sm-9 no-padding-right">
                            <input name="partnerAddress" class="form-control">
                        </div>
                    </div>
                    <hr class="wide contact-split">
                    <div class="form-group col-sm-12 contactList">
                        <label class="control-label col-sm-2 no-padding-right">联系人名单
<span class="control-label mandatory">*</span></label>
                        <div class="col-sm-10">
                            <div class="col-sm-2 no-padding">
                                <input name="type" value="首要" class="form-control" readonly="readonly">
                            </div>
                            <div class="col-sm-4">
                                <input name="name" type="text" class="form-control" placeholder="联系人姓名">
                            </div>
                            <div class="col-sm-5 no-padding-right">
                                <input name="tel" type="text" class="form-control" placeholder="联系电话">
                            </div>
                            <i class="fa fa-plus-circle blue linkmanAdd control-label add-button"></i>
                            <i class="fa fa-minus-circle danger linkmanAdd control-label add-button" style="display:inline;line-height: 33px;"></i>
                        </div>
                    </div>
                    <hr class="wide bankCard-split">
                    <div class="form-group col-sm-12 bankCard">
                        <label class="control-label col-sm-2 no-padding-right">银行卡信息
<span class="control-label mandatory">*</span></label>
                        <div class="col-sm-10">
                            <div class="col-sm-2 no-padding">
                                <input name="bank" type="text" class="form-control" placeholder="开户行">
                            </div>
                            <div class="col-sm-4">
                                <input name="detail" type="text" class="form-control" placeholder="开户行名称">
                            </div>
                            <div class="col-sm-2">
                                <input name="user" type="text" class="form-control" placeholder="开户人">
                            </div>
                            <div class="col-sm-3 no-padding">
                                <input name="account" type="text" class="form-control" placeholder="账号">
                            </div>
                            <i class="fa fa-plus-circle blue bankcardAdd control-label add-button"></i>
                            <i class="fa fa-minus-circle danger bankcardAdd control-label add-button" style="display:inline;line-height: 33px;"></i>
                        </div>
                    </div>
                    <hr class="wide bankReturn-split">
                    <div class="form-group col-sm-12 rebates">
                        <label class="control-label col-sm-2 no-padding-right">返款账号信息
<span class="control-label mandatory">*</span></label>
                        <div class="col-sm-10">
                            <div class="col-sm-2 no-padding">
                                <input name="bank_return" type="text" class="form-control" placeholder="开户行">
                            </div>
                            <div class="col-sm-4">
                                <input name="detail_return" type="text" class="form-control" placeholder="开户行名称">
                            </div>
                            <div class="col-sm-2">
                                <input name="user_return" type="text" class="form-control" placeholder="开户人">
                            </div>
                            <div class="col-sm-3 no-padding">
                                <input name="account_return" type="text" class="form-control" placeholder="账号">
                            </div>
                            <i class="fa fa-plus-circle blue rebatesAccount control-label add-button"></i>
                            <i class="fa fa-minus-circle danger rebatesAccount control-label add-button" style="display:inline;line-height: 33px;"></i>
                        </div>
                    </div>
                    <hr class="wide">
                    <div class="form-group modal-footer">
                        <div class="col-sm-2 col-sm-offset-4">
                            <input type="submit" class="btn btn-primary form-control" value="确定" />
                        </div>
                        <div class="col-sm-2">
                            <button type="button" class="btn btn-danger form-control" data-dismiss="modal">取消</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>


<!--日期插件-->
<script src="${ctx_static }/dep/assets/js/datetime/moment.js"></script>
<script src="${ctx_static }/dep/assets/js/datetime/daterangepicker.js"></script>

<script>
//table初始化_
var InitiateSimpleDataTable = function () {

    return {
        init: function () {
            //Datatable Initiating
            var oTable = $('#partnerTable').dataTable({
                "bPaginate": true,  //是否显示分页
                "iDisplayLength": 10,
                "bLengthChange": false,//每页显示的记录数
                "bFilter": false, //搜索栏
                "bSort": true, //是否支持排序功能
                "bInfo": true, //显示表格信息
                "bAutoWidth": false,  //自适应宽度
                "bStateSave": true, //保存状态到cookie *************** 很重要 ， 当搜索的时候页面一刷新会导致搜索的消失。使用这个属性就可避免了
                //"sPaginationType": "", //分页，一共两种样式，full_numbers和two_button(默认)
                "sAjaxSource": ctx + '/bizPartner/getAll',
                "fnServerData": retrieveData,//用于替换默认发到服务端的请求操作
                "bServerSide": true,
                "bDestroy": true,
                "bRetrieve": false,
                "oLanguage": {
                    "sLengthMenu": "每页显示 _MENU_ 条记录",
                    "sZeroRecords": "抱歉， 没有找到",
                    "sInfo": "从 _START_ 到 _END_ / 共 _TOTAL_ 条数据",
                    "sInfoEmpty": "找不到相关数据",
                    "sInfoFiltered": "数据表中共为 _MAX_ 条记录)",
                    "sProcessing": "正在加载中...",
                    "sSearch": "搜索",
                    "oPaginate": {
                        "sFirst": "首页",
                        "sPrevious": "前一页",
                        "sNext": "后一页",
                        "sLast": "尾页"
                    },
                },
                "aoColumns": [
                    {
                        "mDataProp": "partnerId",
                        "bSortable": false,
                        'sClass': "text-center",
                        "mRender": function (data, type, full) {
                            return "<label> <input type='checkbox' class='slaver'> <span class='text'></span> </label>";
                        }
                    },
                    {"mDataProp": "partnerCode", "bSortable": true, 'sClass': "text-center"},
                    {"mDataProp": "sysDepartment.fullName", "bSortable": true, 'sClass': "text-center"},
                    {"mDataProp": "partnerName", "bSortable": true, 'sClass': "text-center"},
                    {"mDataProp": "partnerShortName", "bSortable": true, 'sClass': "text-center"},
                    {
                        "mDataProp": "contact",
                        "bSortable": false,
                        'sClass': "text-center",
                        "mRender": function (data, type, full) {
                            return JSON.parse(data)[0].name;
                        }
                    },
                    {
                        "mDataProp": "contact",
                        "bSortable": false,
                        'sClass': "text-center",
                        "mRender": function (data, type, full) {
                            return JSON.parse(data)[0].tel;
                        }
                    },
                    {
                        "mDataProp": "enable",
                        "bSortable": false,
                        'sClass': "text-center",
                        "mRender": function (data, type, full) {
                            return data ? '<a href="#" data-id="' + full.partnerId + '" class="btn btn-use btn-xs status-btn"><i class="fa fa-check-square-o"></i> 启用</a>' : '<a href="#" data-id="' + full.partnerId + '" class="btn btn-nouse btn-xs status-btn"><i class="fa fa-ban"></i> 禁用</a>';
                        }
                    },
                    {
                        "mDataProp": "partnerId",
                        "bSortable": false,
                        'sClass': "text-center",
                        "mRender": function (data, type, full) {
                            return "<a href='#' data-id='" + data + "' class='btn btn-info btn-xs contract' "+(full.enable == 0 ? 'disabled' : '')+"> <i class='fa fa-edit'></i> 合同管理</a>" +
                                "<shiro:hasPermission name='bizPartner:edit'><a href='#' data-record='" + JSON.stringify(full) + "' class='btn btn-info btn-xs edit' "+(full.enable == 0 ? 'disabled' : '')+"> <i class='fa fa-edit'></i> 编辑</a></shiro:hasPermission>";
                        }
                    },
                ],
                "aoColumnDefs": [{
                    sDefaultContent: '',
                    aTargets: ['_all']
                }],

            });

        }

    };

}();

</script>

<script src="${ctx_static }/home/configuration/js/partnerManage.js"></script>
